<template>
	<view class="content">
		<u-navbar title="发货信息" :autoBack="true">
		</u-navbar>
		<template v-if="[0,1].includes(info.take_over_way)">
			<view class="top">
				<view class="s1">
					<text class="c1">发货信息：</text>
					<text class="c2">{{ info.send_out_info }}</text>
				</view>

				<view class="s1">
					<text class="c1">物流信息：</text>
					<text class="c2">{{ info.logistics_info }}</text>
				</view>

				<view class="s1">
					<text class="c1">照片上传：</text>
					<text class="c3">
						<image :src="v.url" v-for="(v, i) in info.send_out_images_url" :key='i'></image>
					</text>
				</view>
			</view>

			<view class="but">
				<view class="s2" v-if="info.status == 2" @click="onSend()">
					<text>确认收货</text>
				</view>

				<view class="s2" v-if="info.status == 3">
					<text>已收货</text>
				</view>

				<view class="s2" v-if="info.status == 1">
					<text>未收货</text>
				</view>

			</view>
		</template>
		<template v-if="[2].includes(info.take_over_way)">
			<view class="top">
					<text class="c2">当前发货方式为自取，如已自取请点击“确认收货”</text>
				
			</view>

			<view class="but">
				<view class="s2" v-if="info.status == 2" @click="onSend()">
					<text>确认收货</text>
				</view>

				<view class="s2" v-if="info.status == 3">
					<text>已收货</text>
				</view>

				<view class="s2" v-if="info.status == 1">
					<text>未收货</text>
				</view>

			</view>
		</template>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				info: {},
			};
		},
		onLoad(options) {
			this.id = options.id
		},
		onShow() {
			this.getInfo();
		},
		methods: {
			getInfo() {
				this.$API.getUserInfo({
					id: this.id
				}).then(res => {
					this.info = res.data;
				});
			},
			onSend() {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '是否确认收货？',
					success: function(res) {
						if (res.confirm) {
							that.$API.activitySendOutIn({
								id: that.info.id
							}).then(res => {
								uni.redirectTo({
									url: '/pages/my/activity'
								})
							});
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		width: 670rpx;
		margin: 0 auto;
	}

	.top {
		@include flex(column);
		width: 590rpx;
		padding: 52rpx 40rpx;
		background-color: #fff;
		border-radius: 48rpx;
		margin: 50rpx auto 0 auto;

		.s1 {
			@include flex;
			position: relative;
			align-content: center;
			margin-top: 46rpx;

			.c1 {
				width: 150rpx;
				font-size: 28rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: 400;
				color: #91929E;
				line-height: 32rpx;
				margin-right: 20rpx;
				text-align: right;
			}

			.c2 {
				width: 400rpx;
				font-size: 30rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: 400;
				color: #0A1629;
				line-height: 32rpx;
				overflow: hidden;
			}

			.c3 {
				width: 420rpx;
				@include flex;
				flex-wrap: wrap;

				image {
					width: 176rpx;
					height: 176rpx;
					border-radius: 16rpx;
					margin-right: 32rpx;
				}
			}
		}
	}


	.but {
		@include flex;
		margin-top: 60rpx;
		margin-bottom: 60rpx;

		.s2 {
			width: 290rpx;
			height: 96rpx;
			background: #7677EB;
			box-shadow: 0 12rpx 24rpx 0 rgba(63, 140, 255, 0.2637);
			border-radius: 28rpx;
			margin: 0 auto;
			text-align: center;

			text {
				font-size: 30rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 96rpx;
			}
		}
	}
</style>